//
//  UserModuleResultParser.m
//  DemoProject
//
//  Created by mouxiaochun on 16/3/17.
//  Copyright © 2016年 mmc. All rights reserved.
//

#import "MainPageResultParser.h"
#import "MainPageMethods.h"
#import "ParserObjects.h"
#import "QHPingJiaObj.h"
#import "QHOrderObj.h"
#import "QHDetailOrderObj.h"
#import "QHMainPageObj.h"
#import "QHFinacialMainObj.h"
#import "QHLookDetailRouteObj.h"
#import "QHRouteEvaObj.h"


@implementation AIRequest (MainPage)

- (void) MainPageModuleHander:(id)responseObject responseData:(NSData *)responseData {
    
    DebugLog(@"responseObject->%@",responseObject);
    
    NSDictionary *result = [responseObject copy];
    
    if (!result || result.count == 0) {
        
        [self excuteBlock];
        return;
    }
    NSString *msg = [responseObject objectForKey:@"message"];
    self.result.message = msg;
    self.result.code = [responseObject objectForKey:@"result_code"];
    if ([self.result.code isEqualToString:@"0"]) {
        self.result.success = YES;
        
    }else{
        self.result.success = NO;
        
    }
    id dic = [DeviceUtility decryptUseDES:responseObject[@"result_data"] key:YQH_DESEncrypt_Key];
    if ([dic isKindOfClass:[NSDictionary class]]) {
        dic = [NSDictionary dictionaryWithDictionary:dic];
        
    }else if ([dic isKindOfClass:[NSArray class]]){
        dic = [NSArray arrayWithArray:dic];
    }else{
        NSLog(@"%@",responseObject[@"result_data"]);
    
    }
    
    
    
    
    //处理结果就像下面这样 ，依次添加.......  不懂
    //更改司机接单状态
    if ([self.method isEqualToString:_changeDriverOrderState]) {
        NSLog(@"更改司机接单状态_changeDriverOrderState%@",dic);
        
        
       // NSDictionary *registData = [dic getObject:@"QHSignup"];
        
        [self excuteBlockWithObject:dic];
        
        
    }else
   // 首页数据展示
    if ([self.method isEqualToString:_getDriverMainInfo]) {
      
        NSLog(@"首页数据展示_getDriverMainInfo%@",dic);
        
        id object = [dic getObject:@"QHMainPageObj"];
        
        [self excuteBlockWithObject:object];
        
               
    }else
    //获取消息数据
    if ([self.method isEqualToString:_getDriverMessageList]) {
        NSLog(@"解析_getDriverMessageList%@",dic);
//
        dic = [dic getObjectsFromArrayList:@"QHMessageObj"];
        
        [self excuteBlockWithObject:dic];
        
    }else
    //获取消息详情
    if ([self.method isEqualToString:_getMessDetails]) {
//#pragma mark模型中还有模型
//        QHPingJiaObj *mQHPingJiaObj = [dic getObject:@"QHPingJiaObj"];
//        
//        if (dic[@"eavList"]) {
//            
//            NSArray *eavList = dic[@"eavList"];
//            
//            mQHPingJiaObj.eavList =[eavList getObjectsFromArrayList:@"QHEvaObj"];
//            
//        }
//        [self excuteBlockWithObject:mQHPingJiaObj];
//        
        
    }else
    //删除消息
    if ([self.method isEqualToString:_deleteMess]) {
//        NSDictionary *object = [dic getObject:@"QHSignup"];
        [self excuteBlockWithObject:dic];

    }else
    //确认接单
    if ([self.method isEqualToString:_driverConfirmOrders]) {
        NSLog(@"解析确认接单_driverConfirmOrders%@",dic);
        
//        NSDictionary *object = [dic getObject:@"QHSignup"];
        [self excuteBlockWithObject:dic];
//        
    }else
    //获取司机订单列表
    if ([self.method isEqualToString:_driverOrderList]) {
        
        NSLog(@"解析_driverOrderList%@",dic);
        
        dic = [dic getObjectsFromArrayList:@"QHOrderObj"];
      
        [self excuteBlockWithObject:dic];
        
    }else
    //订单信息
    if ([self.method isEqualToString:_pullOrderInfo]) {
               NSLog(@"解析_pullOrderInfo%@",dic);
        //
        //        NSDictionary *object = [dic getObject:@"QHSignup"];
        //        [self excuteBlockWithObject:object];
        //        
    }else
    //订单详情信息
    if ([self.method isEqualToString:_getOrderDetails]) {
        NSLog(@"解析_getOrderDetails%@",dic);
        
                NSDictionary *object = [dic getObject:@"QHDetailOrderObj"];
                [self excuteBlockWithObject:object];
        
    }else
    //删除订单
    if ([self.method isEqualToString:_removeOrder]) {
        //        NSLog(@"解析_removeOrder%@",dic);
        //
        //        NSDictionary *object = [dic getObject:@"QHSignup"];
               [self excuteBlockWithObject:dic];
        //        
    }else
    //完成出游
    if ([self.method isEqualToString:_completeTravel]) {
                NSLog(@"解析_completeTravel%@",dic);
        //
        //        NSDictionary *object = [dic getObject:@"QHSignup"];
               [self excuteBlockWithObject:dic];
        //        
    }
   else
    
    //获取线路详情介绍
    if ([self.method isEqualToString:_getTourisDetails]) {
        NSLog(@"解析_getTourisDetails%@",dic);
       
     
               NSDictionary *object = [dic getObject:@"QHLookDetailRouteObj"];
                [self excuteBlockWithObject:object];
        
    }
    else
        
        //获取服务介绍
        if ([self.method isEqualToString:_getServiceIntroduction]) {
            NSLog(@"解析服务介绍_getServiceIntroduction%@",dic);
            
            
          //  NSDictionary *object = [dic getObject:@"QHLookDetailRouteObj"];
            [self excuteBlockWithObject:dic];
            
        }
    
    else
        
        //获取线路评价
        if ([self.method isEqualToString:_getTourisEvaluate]) {
            NSLog(@"解析_getTourisEvaluate%@",dic);
            
            
         dic = [dic getObjectsFromArrayList:@"QHRouteEvaObj"];
          
            [self excuteBlockWithObject:dic];
        
        }
    else
    //获取游客列表
    if ([self.method isEqualToString:_getOrdertouristList]) {
        NSLog(@"解析_getOrdertouristList%@",dic);
        
        //
                dic = [dic getObjectsFromArrayList:@"QHDetailOrderObj"];
        
                [self excuteBlockWithObject:dic];
        
    }else
    ////财务数据
    if ([self.method isEqualToString:_getDriverFinanceInfo]) {
        NSLog(@"解析_getDriverFinanceInfo%@",dic);
       
        
               id object = [dic getObject:@"QHFinacialMainObj"];
               [self excuteBlockWithObject:object];
        
    }
    
    else  {
        [self excuteBlock];
    }
}

@end
